<template>
  <v-layout title="修改销售合同">
    <el-row type="flex" justify="center">
      <el-col :lg="12" :md="12" :sm="28" :xs="24">
        <v-form
          :form-title="formTitle"
          :form-data="formData"
          label-width="100px"
        >
          <template
            slot="uploadImg"
            slot-scope="scope"
          >
            <el-form-item :label="scope.info.cn">
              <uploadFile
                :file-list="fileList"
                @on-success="handleSuccess"
              />
            </el-form-item>
          </template>

        </v-form>
        <!--<div>-->
        <!--<div class="subtitle">-->
        <!--合同包含订单:-->
        <!--</div>-->
        <!--<v-table-->
        <!--:table-title="tableTitle"-->
        <!--:table-data="tableData"-->
        <!--:showPagination="false"-->
        <!--:select="false"-->
        <!--:editable="false"-->
        <!--:deletable="false"-->
        <!--:readable="true"-->
        <!--@read="read"-->
        <!--&gt;-->

        <!--</v-table>-->
        <!--</div>-->

        <!--开票进度-->
        <!--<el-row class="mt15">-->
        <!--<div class="subtitle">-->
        <!--合同审批记录：-->
        <!--</div>-->
        <!--<v-messageBox-->
        <!--:messages="messages"-->
        <!--/>-->
        <!--</el-row>-->

        <!--<el-row type="flex" justify="end" class="pdt15">-->
        <!--<el-button type="primary" size="small" @click="reset">撤销修改</el-button>-->
        <!--<el-button type="primary" size="small" @click="submit">确定</el-button>-->
        <!--</el-row>-->
      </el-col>
    </el-row>

  </v-layout>
</template>

<script>
import auth from '@/mixins/auth'
import uploadFile from '@/views/components/uploadFiles'

export default {
  components: { uploadFile },
  mixins: [auth],
  data() {
    return {
      showModel: false,

      // 已上传合同
      fileList: [],

      formData: {},

      tableTitle: [
        {
          cn: '序号',
          en: 'id'
        },
        {
          cn: '订单编号',
          en: 'number'
        },
        {
          cn: '公众号',
          en: 'tencent'
        },
        {
          cn: '版位',
          en: 'position'
        },
        {
          cn: '发文日期',
          en: 'publish_at'
        },
        {
          cn: '是否预订',
          en: 'ordered'
        }
      ],
      tableData: [
        {
          id: '1',
          number: '2134234',
          tencent: '杭州杭州',
          position: '头条',
          publish_date: '2018-01-01',
          ordered: '否'
        }
      ],

      messages: [
        {
          time: '2017-01-01 00:00:00',
          msg: '二狗通过了商务李四的*****审核'
        }
      ]
    }
  },
  computed: {
    formTitle() {
      return (
        [
          {
            cn: '合同名称',
            en: '合同名称',
            disabled: true
          },
          {
            cn: '合同编号',
            en: '合同编号',
            disabled: true
          },
          {
            cn: '合同附件',
            en: '合同附件',
            disabled: true
          },
          {
            cn: '客户名称',
            en: '客户名称',
            disabled: true
          },
          {
            cn: '合同金额',
            en: '合同金额',
            disabled: true
          },
          {
            cn: '回款状态',
            en: '回款状态',
            type: 'select',
            list: [
              {
                label: '未收款',
                value: '1'
              },
              {
                label: '部分收款',
                value: '2'
              },
              {
                label: '已完成',
                value: '3'
              }
            ],
            disabled: true
          },
          {
            cn: '已收款金额',
            en: '已收款金额',
            disabled: true
          },
          {
            cn: '未收款金额',
            en: '未收款金额',
            disabled: true
          },
          {
            cn: '收款比例',
            en: '收款比例',
            disabled: true
          },
          {
            cn: '签订日期',
            en: '签订日期',
            type: 'time',
            disabled: true
          },
          {
            cn: '到期日期',
            en: '到期日期',
            type: 'time',
            disabled: true
          },
          {
            cn: '合同状态',
            en: '合同状态',
            type: 'select',
            list: [
              {
                label: '签约',
                value: '签约'
              },
              {
                label: '执行中',
                value: '执行中'
              },
              {
                label: '完毕',
                value: '完毕'
              },
              {
                label: '意外终止',
                value: '意外终止'
              }
            ],
            disabled: true
          },
          {
            cn: '合同类型',
            en: '合同类型',
            type: 'select',
            list: [
              {
                label: '空白',
                value: '0'
              },
              {
                label: '直销合同',
                value: '直销合同'
              },
              {
                label: '代理合同',
                value: '代理合同'
              },
              {
                label: '服务合同',
                value: '服务合同'
              },
              {
                label: '快销合同',
                value: '快销合同'
              }
            ],
            disabled: true
          },
          {
            cn: '签订人',
            en: '签订人',
            disabled: true
          },
          {
            cn: '付款方式',
            en: '付款方式',
            type: 'select',
            disabled: true,
            list: [
              {
                label: '网银转账',
                value: '1'
              },
              {
                label: '现金',
                value: '2'
              },
              {
                label: '支票',
                value: '3'
              },
              {
                label: '电汇',
                value: '4'
              },
              {
                label: '承诺汇票',
                value: '5'
              },
              {
                label: '银行卡',
                value: '6'
              }
            ]
          },
          {
            cn: '归档状态',
            en: 'file_status',
            type: 'select',
            disabled: !this.assistantRole,
            list: [
              {
                label: '是',
                value: '1'
              },
              {
                label: '否',
                value: '0'
              }
            ]
          },
          {
            cn: '归档时间',
            en: '归档时间',
            type:'time',
            disabled: !this.assistantRole
          },
          {
            cn: '备注',
            en: 'notes',
            type: 'textarea'
          }
        ]
      )
    }
  },
  created() {
    const details = this.$route.params.details
    if (details) {
      localStorage.setItem('details', JSON.stringify(details))
      this.formData = this.$route.params.data
    }

    this.formData = localStorage.getItem('details') && JSON.parse(localStorage.getItem('details')) || {}
    const attach = this.formData.合同附件 && JSON.parse(this.formData.合同附件)[0]
    this.formData.合同附件 = attach ? attach.filename.replace(new RegExp('.doc\|.docx'), '') : ''
    this.formData.url = attach ? attach.attachIndex : ''
  },
  destroyed() {
    localStorage.removeItem('details')
  },
  methods: {

    // 文件上传成功
    handleSuccess(res, file, fileList) {
      console.log(res, file, fileList)
    },

    read(val) {

    },
    reset() {

    },
    submit() {

    }
  }
}
</script>

<style scoped>

</style>
